<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Categories
 *
 * @author thanhdx
 */
class Categories extends CActiveRecord {

    //put your code here
    public $id;
    public $name;

    /**
     * Returns the static model of the specified AR class.
     * @return Users the static model class
     */
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'tbl_categories';
    }
    
    public function attributeLabels() {
        return array(
            'name'=>'Tên',
            'pos'=>'Vị trí'
        );
    }
    
    public function rules(){
        return array(
            array('name','required'),
            array('pos','numerical','integerOnly'=>true),
        );
    }
    
    /**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('pos',$this->pos,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

}

?>
